<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>初始vue</title>
    <!-- 引入vue -->
    <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>
    <!-- 准备好一个容器 -->
    <div id="root">
        <form action="" @submit.prevent="send">
            <label for="demo">账号:</label>
            <input type="text" id="demo" v-model="userInfo.account"><br> <br>
            密码: <input type="password" v-model="userInfo.password"> <br> <br>
            年龄: <input type="age" v-model="userInfo.age"> <br> <br>
            性别:
            男 <input type="radio" name="sex" v-model="userInfo.sex" value="male">
            女 <input type="radio" name="sex" v-model="userInfo.sex" value="female"><br> <br>
            爱好:
            听音乐 <input type="checkbox" v-model="userInfo.hobby" value="music">
            写代码 <input type="checkbox" v-model="userInfo.hobby" value="code">
            打游戏 <input type="checkbox" v-model="userInfo.hobby" value="game"> <br> <br>
            校区选择
            <select v-model="userInfo.city">
                <option value="">请选择校区</option>
                <option value="shanghai">上海</option>
                <option value="beijing">北京</option>
                <option value="guangdong">广东</option>
                <option value="shenzhen">深圳</option>
            </select> <br> <br>
            其他信息:
            <textarea v-model="userInfo.other"></textarea><br> <br>
            <input type="checkbox" v-model="userInfo.agree"> 阅读并接收 <a href="http://cnblogs.com/zhaostudy/">《用户协议》</a>
            <button>提交</button>
        </form>
    </div>
    <script>
        Vue.config.productionTip = false // 以阻止 vue 在启动时生成生产提示。

        // 创建Vue实例
        new Vue({
            el: "#root",
            data: {
                userInfo: {
                    account: '',
                    password: '',
                    sex: 'female',
                    age: '',
                    hobby: [],
                    city: '',
                    other: '',
                    agree: ''
                },

            },
            methods: {
                send ()
                {
                    console.log(JSON.stringify(this.userInfo));
                }
            },
        })
    </script>
</body>

</html>